package com.jichangxiu.framework.mybatis;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jichangxiu.common.entity.bo.BasePage;
import com.jichangxiu.common.utils.ServletUtils;

/**
 * BaseServiceImpl:
 *
 * @author Jcx
 * @create 2023-04-04 11:47
 */
public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {

    /**
     * 设置请求分页数据
     */
    protected <E> Page<E> startPage() {
        BasePage basePage = new BasePage();
        basePage.setPageNum(Convert.toInt(ServletUtils.getParameter("pageNum"), BasePage.DEFAULT_PAGE_NUM));
        basePage.setPageSize(Convert.toInt(ServletUtils.getParameter("pageSize"), BasePage.DEFAULT_PAGE_SIZE));
        basePage.setOrderByColumn(ServletUtils.getParameter("orderByColumn"));
        basePage.setIsAsc(ServletUtils.getParameter("isAsc"));
        return basePage.build();
    }

}
